<%--
 *  File:    DMSMain.jsp
 *  @Author: DC
 *  Date:    2011/09/13
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page import="java.text.*" %>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>



<% //--------------------------------------  setting logger --%>
<%
  Category cat = Category.getInstance("jsp.DMSMain");
  //init param
  String strModuleName = "COM";
  String privilegeCode = "FP0201";
  System.out.println("*************************"+privilegeCode);
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<iframe name="reloadHandler" style="display:none" ></iframe>
<html>
<head>
<PageFlow:CheckPageFlow pageName="p_mdsmain"/>
<%--@ include file="/inc/CatchError.inc" --%>
<%
	//params
     String viewflag = "";

     if(pageContext.getAttribute("viewflag") != null&&((String)pageContext.getAttribute("viewflag")).equals("view")) {

           viewflag = "view";
     }


    String strIsDefault = null;
	String paraIsDefault = "";
	String isTdNeed = "td-text";
	if("Y".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=Y";
		paraIsDefault = "Y";
		isTdNeed = "need";
	}else if ("N".equals(request.getParameter("isdefault"))) {
		strIsDefault = "&isdefault=N";
		paraIsDefault = "N";
	}
  String isNew = "";
  if("Y".equals(request.getParameter("isNew"))) {
		isNew = "Y";
	}else if ("N".equals(request.getParameter("isNew"))) {
		isNew = "N";
	}else  {
		isNew = null;
	}System.out.print(isNew);
  //params end
  
  HashMap mdsinfo = null;
  String valuemdsid = null;
  String dateOpt = null;
  mdsinfo = (HashMap)pageContext.getAttribute("mdsinfo");
	  if(mdsinfo != null&&mdsinfo.size()!=0) {
  		if(isNew!=null && isNew.equals("Y")){
  			valuemdsid = JspHelper.filterNull( mdsinfo.get("mdsid") ).toString();
	  	}
		dateOpt = JspHelper.filterNull( mdsinfo.get("createdate") ).toString();
      }else {
    	  mdsinfo = new HashMap();
    	  mdsinfo.put("status",new Integer(10));
    	  mdsinfo.put("createdate",new java.sql.Date(System.currentTimeMillis()));
		  pageContext.setAttribute("mdsinfo",mdsinfo);
		  valuemdsid = "";
		  mdsinfo = (HashMap)pageContext.getAttribute("mdsinfo");
      }
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  
  
  
	String dateFormat = (String)session.getAttribute("dateformat");
	if(dateFormat==null)dateFormat = "yyyy-MM-dd";
  
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<%@ include file ="/inc/NewCalendar.inc" %>
<%@ include file="/inc/SummaryDivision.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>
<script language="JavaScript">




function changeStatus()
{
  if(cform.status1.value == -1)
  {
	  cform.valuename.value = " ";
  }
  else
  {
	 // alert("status1 : " + cform.status1.value);
    for (i = 0; i < cform.status1.options.length; ++i)
    {
      var opt = cform.status1.options[i];
      if (opt.selected)
      {
    	  cform.valuename.value = opt.text;
      }
    }
  }
}


function page_save()
{	
	if(!checkForm(cform))   return;
	emptyToNull(cform);
	var frm = document.cform;
	frm.actionname.value = "save";
	frm.target = "_parent";
	frm.submit();
}
function page_submit()
{
	if(!checkForm(cform))   return;

   if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>") )  return;
	var frm = document.cform;
	frm.actionname.value = "submit";
	frm.target = "_parent";
	frm.submit();
}
function page_back()
{  
  parent.location.href = "MDSManagement.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%><%=JspHelper.filterNull( strIsDefault )%>";
}

</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0">
   <form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
      <input type="hidden" name="pagename" value="p_mdsmain">
      <input type="hidden" name="actionname">
	  <input type="hidden" name="orgid">
      <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
	  <input type="hidden" name="isNew" value="<%= isNew %>">
	  <%if(isNew!=null && isNew.equals("Y")) { %>
	  	<input type="hidden" name="createdate" value="<%= OvalTools.getDate() %>">
	  	<custom:hidden name="userinfo" property="userid" scope="session" changedName="maker" />
	    <custom:hidden name="userinfo" property="orgid" scope="session"  />
      
	  <%}%>
	  	 
      <input type="hidden" name="isdefault" value="<%= paraIsDefault %>">
      <custom:hidden name ="mdsinfo" property="mdsid" />
      



    <tr>
      <td valign="top">
        <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
            
           
           <tr>
            <td colspan="4" class="deepblue-left" height="22"> <img src="<%=contextPath %>/images/<%= strLanguageCode %>/quote.gif">
            &nbsp;</td>
          </tr>
         <%	if(viewflag.equals("view")){%>
          <tr>

          <td class="td-text" width="110" ><%= label.getLabelName("L_MainMarketPlan")+ label.getLabelName("L_Code") + label.getLabelName("L_Colon") %></td>
          	<td>

                  &nbsp;<custom:write  name="mdsinfo" property="mdscode" />

               </td>
             <td class="td-text" width="110" ><%= label.getLabelName("L_MainMarketPlan")+ label.getLabelName("L_Name") + label.getLabelName("L_Colon") %></td>
            <td>
				&nbsp;<custom:write  name="mdsinfo" property="mdsname"  />
           	</td>
          </tr>
          
          <tr>
           <td  class="td-text" width="110" ><%= label.getLabelName("L_Logic") + label.getLabelName("L_Colon") %></td>
           	<td>
           	<custom:write property="logicname"  name="mdsinfo"/>
           	</td>
           	
			<td class="td-text" width="110" ><%= label.getLabelName("L_Maker") + label.getLabelName("L_Colon") %></td>
            <td> <custom:write  name="mdsinfo" property="username"   /> </td>
            
          </tr>
          
         <tr>
            <td class="td-text"  width="110" ><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
            <td colspan="3">

               <custom:write property="statusname"  name="mdsinfo"  />
            </td>
          </tr>
          <tr>
          <td class="td-text"width="110" ><%= label.getLabelName("L_Comments") + label.getLabelName("L_Colon") %></td>
          <td colspan="3" ><custom:textarea readonly="true" name="mdsinfo" property="comments" cols="120" rows="4" />
               </td>
           </tr>
<%}else{ %>
           
      <tr>
       	   <td class="td-text" width="110" ><%= label.getLabelName("L_MainMarketPlan")+ label.getLabelName("L_Code") + label.getLabelName("L_Colon") %></td>
          	<td>
                  <%if("Y".equals(isNew) ){%>
                  &nbsp;<custom:text  name="mdsinfo" property="mdscode" />
				  <%}else{%>
                  <custom:text  readonly="true" name="mdsinfo" property="mdscode" command="notnull" />
              		 <%}%>
               </td>
             <td class="td-text" width="110" ><%= label.getLabelName("L_MainMarketPlan")+ label.getLabelName("L_Name") + label.getLabelName("L_Colon") %></td>
            <td>
				&nbsp;<custom:text  name="mdsinfo" property="mdsname"  />
           	</td>
          </tr>
          
         <tr>
           <td  class="td-text" width="110" ><%= label.getLabelName("L_Logic") + label.getLabelName("L_Colon") %></td>
           	<td>
           	<custom:selectdic property="logic" dictType="Logic" name="mdsinfo" defaultValueCost="" label="L_Logic" />
           	</td>
           	
            <td class="need" width="110" ><%= label.getLabelName("L_Maker") + label.getLabelName("L_Colon") %></td>
            <td>
                <%if(mdsinfo.get("mdsid")!=null){%>
                 <oval:hidden name="mdsinfo" property="maker"  />
                 <custom:write  name="mdsinfo" property="username"   />

                <%}else{%>
                    <oval:hidden name="userinfo" property="userid" scope="session" changedName="maker" />
                    <oval:write name="userinfo" property="username" scope="session"   />
               <%}%>
            </td>
          </tr>
          
         <tr>
            <td class="td-text"  width="110" ><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
            <td colspan="3">

               <custom:selectdic property="status" dictType="Status" name="mdsinfo" valueCriteria="41,28" defaultValueCost="" label="L_Status" />
            </td>
          </tr>
          <tr>
          <td class="td-text"width="110" ><%= label.getLabelName("L_Comments") + label.getLabelName("L_Colon") %></td>
          <td colspan="3" ><custom:textarea readonly="true" name="mdsinfo" property="comments" cols="120" rows="4" />
               </td>

          </tr>
   <%}%>        
        </table>
      </td>
    </tr>
    <tr>
      <td class="summary_top"></td>
    </tr>
    <tr>
    <td height="49" class="td_center">
	<%if(!viewflag.equals("view")){%>
        <a onclick="page_save()"><custom:button type="1" label="L_Save" imgsrc="back.gif" border="0" style="width:60" /></a>
    <%}%>
        <a onclick="javascript:page_back()"><custom:button type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60"/></a>


    </td>
    </tr>
</form>
</table>
<script language="JavaScript" src="../../js/Calendar.js" ></script>
<%@include file="/inc/AlertError.inc"%>
</body>
</html>


           		